package cn.stylefeng.guns.modular.yingbao.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import  cn.stylefeng.guns.modular.yingbao.entity.UserBank;
import  cn.stylefeng.guns.modular.yingbao.model.params.UserBankParam;
import  cn.stylefeng.guns.modular.yingbao.service.UserBankService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import oracle.jdbc.proxy.annotation.Post;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 开户行列表控制器
 *
 * @author zs
 * @Date 2019-12-12 14:02:51
 */
@CrossOrigin
@Controller
@RequestMapping("/userBank")
@Api(tags = "开户行")
public class UserBankController extends BaseController {

    private String PREFIX = "/userBank";

    @Autowired
    private UserBankService userBankService;

    /**
     * 跳转到主页面
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/userBank.html";
    }

    /**
     * 新增页面
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/userBank_add.html";
    }

    /**
     * 编辑页面
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/userBank_edit.html";
    }

    /**
     * 新增接口
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(UserBankParam userBankParam) {
        this.userBankService.add(userBankParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(UserBankParam userBankParam) {
        this.userBankService.update(userBankParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(UserBankParam userBankParam) {
        this.userBankService.delete(userBankParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(UserBankParam userBankParam) {
        UserBank detail = this.userBankService.getById(userBankParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author zs
     * @Date 2019-12-12
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(UserBankParam userBankParam) {
        return this.userBankService.findPageBySpec(userBankParam);
    }

    @PostMapping("queryAll")
    @ResponseBody
    @ApiOperation("查询所有开户行")
    public ResponseData queryAll(){
        return this.userBankService.queryAll();
    }

    @PostMapping("queryById")
    @ResponseBody
    public ResponseData queryById(String id){
        return this.userBankService.queryById(id);
    }
}


